<template>
  <div class="scan-code-login">
    <div id="login-code"></div>
  </div>
</template>

<script>
  import GlobalData from 'utils/globalData';

  export default {
    data() {
      return {};
    },

    mounted() {
      if (window.WxLogin) {
        this.createLoginCode();
      } else {
        let url = 'https://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js';
        $.getScript(url, () => {
          this.createLoginCode();
        });
      }
    },

    methods: {
      createLoginCode() {
        new WxLogin({
          self_redirect: false,
          id: "login-code",
          appid: "wx1cf065e04942c3a5",
          scope: "snsapi_login",
          redirect_uri: `${GlobalData.baseUrl}/homeMain`,
          style: "",
          href: ""
        });
      }
    }
  };

</script>

<style lang="scss" scoped>
  .scan-code-login {
    height: 100%;

    #login-code {
      text-align: center;
    }
  }

</style>
